<?php

class UserAccountDAO {
	
	public $link;
	
	public function __construct() {
		$this->link = mysql_connect("localhost:3306", "root", "");
		mysql_select_db("fyp") or die(mysql_error());
		
	}
	
	public function checkEmailExists($emailAddress) {
		$result = mysql_query("SELECT * FROM User WHERE u_email = '$emailAddress'") or die(mysql_error());
		
		if(mysql_num_rows($result) >= 1)
			return false;
		else 
			return true;
		
	}
	
	public function createAccount($name, $surname, $emailAddress, $password, $activationKey) {
		mysql_query("INSERT INTO user (u_email, u_password, u_name, u_surname, u_activation_key, u_activated) VALUES ('$emailAddress', '$password', '$name', '$surname', '$activationKey', '0')") or die(mysql_error());
	}
	
	
	
	public function close() {
		mysql_close();
	}
}

?>